package com.example.zytphone;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.example.zytphone.adapter.RecyclerAdapter;
import com.example.zytphone.base.Huoying;

import java.util.ArrayList;
import java.util.List;

public class ShopActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private RecyclerAdapter recyclerAdapter;
    private List<Huoying> huoyingList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        initData();
        initView();
    }

    private void initData() {
        huoyingList=new ArrayList<>();
        huoyingList.add(new Huoying("冠心病"));
        huoyingList.add(new Huoying("高血糖"));
        huoyingList.add(new Huoying("高血压"));
        huoyingList.add(new Huoying("失眠"));
        huoyingList.add(new Huoying("自选区"));
    }

    //初始化
    private void initView(){
        recyclerView = findViewById(R.id.recycler);
        // 线性布局管理器
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);
        // 用于描述item的适配器
        recyclerAdapter = new RecyclerAdapter(huoyingList);
        recyclerView.setAdapter(recyclerAdapter);
    }
}